package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LocationHistory;
import com.ruoyi.system.service.ILocationHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 位置历史记录Controller
 * 
 * @author ruoyi
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/system/LocationHistory")
public class LocationHistoryController extends BaseController
{
    @Autowired
    private ILocationHistoryService locationHistoryService;

    /**
     * 查询位置历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:LocationHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(LocationHistory locationHistory)
    {
        startPage();
        List<LocationHistory> list = locationHistoryService.selectLocationHistoryList(locationHistory);
        return getDataTable(list);
    }

    /**
     * 导出位置历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:LocationHistory:export')")
    @Log(title = "位置历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LocationHistory locationHistory)
    {
        List<LocationHistory> list = locationHistoryService.selectLocationHistoryList(locationHistory);
        ExcelUtil<LocationHistory> util = new ExcelUtil<LocationHistory>(LocationHistory.class);
        util.exportExcel(response, list, "位置历史记录数据");
    }

    /**
     * 获取位置历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:LocationHistory:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(locationHistoryService.selectLocationHistoryByRecordId(recordId));
    }

    /**
     * 新增位置历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:LocationHistory:add')")
    @Log(title = "位置历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LocationHistory locationHistory)
    {
        return toAjax(locationHistoryService.insertLocationHistory(locationHistory));
    }

    /**
     * 修改位置历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:LocationHistory:edit')")
    @Log(title = "位置历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LocationHistory locationHistory)
    {
        return toAjax(locationHistoryService.updateLocationHistory(locationHistory));
    }

    /**
     * 删除位置历史记录
     */
    @PreAuthorize("@ss.hasPermi('system:LocationHistory:remove')")
    @Log(title = "位置历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(locationHistoryService.deleteLocationHistoryByRecordIds(recordIds));
    }
}
